#!/usr/bin/python
#coding=utf-8
import requests
url = "https://www.baidu.com/"
# 发起get请求
res = requests.get(url=url)
# 获取响应状态码
code = res.status_code
# 响应成功后把响应的内容写入文件中
if code == 200:
    with open('./test.html', 'w') as fp:
        fp.write(res.text)